home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Demos / AppMaker™ 1.5 DEMO / Demo AppMaker™ / Demo AppMaker™.rsrc / TmpP_104_MainMenu < prev    next >
Encoding:
Text File  |  1992-04-08  |  2.7 KB  |  158 lines

  1. { %filename% }
  2. { Created %date% %time% by AppMaker }
  3.  
  4. Unit %unitname%;
  5. Interface
  6.  
  7. Uses
  8.     %if lang = MPW%
  9.         Types,
  10.         Quickdraw,
  11.         Controls,
  12.         Desk,
  13.         Dialogs,
  14.         Events,
  15.         Lists,
  16.         Menus,
  17.         StandardFile,
  18.         TextEdit,
  19.         ToolUtils,
  20.  
  21.     %end if%
  22.     %for each menu gen uses%
  23.  
  24.     Globals,
  25.     ResourceDefs,
  26.     Miscellany;
  27.     
  28. {----------}
  29. Procedure InitTitles;
  30. Procedure LoadMenus;
  31. Procedure DoMenu (menuChoice:    longint);
  32. Procedure UpdateMenus;
  33.  
  34. {----------}
  35. Implementation
  36.  
  37. %if lang = MPW%
  38.     {$D+}
  39.     {$R+}
  40.     {$OV+}
  41.     {$S %unitname%}
  42.  
  43. %end if%
  44. {----------}
  45. Procedure InitTitles;
  46. Begin
  47.     %for each menu gen initTitles%
  48.  
  49. End; {InitTitles}
  50.  
  51. {----------}
  52. Procedure LoadMenus;
  53. Begin
  54.     %for each menu gen get%
  55.  
  56.     %for each menu gen insert%
  57.  
  58.     DrawMenuBar;
  59. End; {LoadMenus}
  60.  
  61. %for each menu gen doApple%
  62. {----------}
  63. Procedure DoMenu     (menuChoice:    longint);
  64. var
  65.     menuID:            integer;
  66.     itemNr:            integer;
  67. Begin
  68.     menuID := HiWord (menuChoice);
  69.     itemNr := LoWord (menuChoice);
  70.     
  71.     case menuID of
  72.         0:
  73.                 {Do nothing};
  74.         %for each menu gen dispatch%
  75.  
  76.     end; {case}
  77.  
  78.     HiliteMenu (0);
  79. End; {DoMenu}
  80.  
  81. {----------}
  82. Procedure UpdateMenus;
  83. var
  84.     frontPeek:        WindowPeek;
  85.     isFront:        boolean;    {is there a front window?}
  86.     isCur:            boolean;    {is there a current window?}
  87.     isDirty:        boolean;    {is it dirty?}
  88.     hasFile:        boolean;    {does it have a file?}
  89.     isSelected:        boolean;    {is anything selected?}
  90.     isDesk:            boolean;    {is the front window a desk acc?}
  91.     isText:            boolean;    {is there a current text field?}
  92.     isScrap:        boolean;    {is there any scrap?}
  93.     menu:            MenuHandle;
  94.     menuBarChanged:    boolean;
  95.     
  96.     {----------}
  97.     Procedure Enable (itemNr:    integer;
  98.                       enabled:    boolean);
  99.     Begin
  100.         if enabled then begin
  101.             EnableItem  (menu, itemNr);
  102.         end else begin
  103.             DisableItem (menu, itemNr);
  104.         end;
  105.     End; {Enable}
  106.     
  107.     {----------}
  108.     Procedure EnableTitle (menu:    MenuHandle;
  109.                              enabled:    boolean);
  110.     Begin
  111.         if enabled <> odd (menu^^.enableFlags) then begin
  112.             menuBarChanged := true;
  113.         end;
  114.         if enabled then begin
  115.             EnableItem  (menu, 0);
  116.         end else begin
  117.             DisableItem (menu, 0);
  118.         end;
  119.     End; {EnableTitle}
  120.     
  121. Begin {UpdateMenus}
  122.  
  123.     menuBarChanged := false;
  124.  
  125.     isFront        := (FrontWindow <> nil);
  126.     isCur        := (curWindow <> nil);
  127.     isDirty     := false;
  128.     hasFile     := false;
  129.     isSelected    := false;
  130.     if isCur then begin
  131.         isDirty        :=  cur^.dirty;
  132.         hasFile        := (cur^.fileNum <> 0);
  133.     end;
  134.  
  135.     isDesk := false;
  136.     if isFront then begin
  137.         frontPeek    := WindowPeek (FrontWindow);
  138.         isDesk        := (frontPeek^.windowKind < 0);
  139.     end;
  140.     isText        := false;
  141.     if isCur then begin
  142.         isText        := (cur^.text <> nil);
  143.     end;
  144.     isScrap        := false;
  145.     if isText then begin
  146.         isSelected    := (cur^.text^^.selStart <> cur^.text^^.selEnd);
  147.         isScrap        := (TEGetScrapLen > 0);
  148.     end;
  149.     
  150.     %for each menu gen enable%
  151.  
  152.     if menuBarChanged then begin
  153.         DrawMenuBar;
  154.     end;
  155. End; {UpdateMenus}
  156.  
  157. End. {%unitname%}
  158.